import { Token } from '@/types/data';
import { LoginAction } from '@/types/store';
import { getToken } from '@/utils/token';

// token
// const initialState: Token = {
//   token: '',
//   refresh_token: '',
// };

const initialState: Token = getToken();

// 保存用户登录成功后的token
export const login = (state = initialState, action: LoginAction): Token => {
  // 用户登录成功后，更新redux中的token
  if (action.type === 'login/token') {
    return action.payload;
  }
  return state;
};
